﻿@using BastInfos.Helpers
@using DataAccess.Helpers

@model IEnumerable<DataAccess.Article>

@{
    ViewBag.Title = "List";
}

<h2>Liste des articles</h2>
<br/>

@using(Html.BeginForm()) {
	<fieldset class="-filter">
		<legend>Filtrer</legend>
		<div>
			<table>
			<tr>
				<td>Statut :</td>
				<td>@Html.DropDownListWithEmpty("Status", new SelectList(new StatusTypeList(), "Id", "Name"), "Tous")</td>
			</tr>
			<tr>
				<td>Rubrique :</td>
				<td>@Html.DropDownListWithEmpty("Category", new SelectList(DataAccess.Article.AvailableCategories, "id_Category", "Description"), "Toutes")</td>
			</tr>
			<tr>
				<td>Nombre d'éléments par page :</td>
				<td>@Html.DropDownList("Page", new SelectList(new string[]{ "10", "20", "50", "Tout" }))</td>
			</tr>
			</table>
			@* TODO: filtre avec date *@
			<input type="submit" value="Filtrer" />
		</div>
	</fieldset>
}
<p>
	<a href="@Url.Action("Create")" style="text-decoration:none;">
		<img src="/Content/images/admin/Add.png" alt="Ajouter" title="Ajouter" height="20px"/>
		Ajouter un Article
	</a>
</p>
<br />
<table border="0" cellpadding="0" cellspacing="0" class="grid" style="text-align:left;">
	<tr>
		<th width="40px" height="20px">Statut</th>
		<th width="40px" height="20px">Option</th>
		<th>Article</th>
		<th width="40px">Création</th>
		<th width="30px">Edition</th>
	</tr>

@for(int i = 0; i < Model.Count(); i++) {
	var item = Model.ElementAt(i);
	<tr class="@if (i % 2 == 0) { <text>even</text> } else { <text>odd</text> }">
		<td style="text-align:center;">
			<img src="/Content/images/admin/Status_@(item.Status).png" alt="@((StatusType)item.Status)" title="@((StatusType)item.Status)" height="40px" />
		</td>
		<td style="text-align:center;">
            @Html.ActionLink("Editer", "Edit", new { id = item.id_Article })
			<br /><br />
			@Html.RouteLink("Voir", "Article", new { title = item.Title, id = item.id_Article }, new { target = "_blank" })
            @*@Html.ActionLink("Voir", "Details", new { id = item.id_Article })*@
        </td>
		<td>
			<strong>@item.Title</strong>
			<br/><em>@item.Category.Description</em>
			<br/>
			<br/>@Html.Raw(item.Introduction)
		</td>
		<td style="text-align:center;">@String.Format("{0:g}", item.CreationDate)</td>
		<td style="text-align:center;">@String.Format("{0:g}", item.EditDate)</td>
	</tr>
}

</table>

